/*
 * Copyright (c) 2024 Huawei Technologies Co.,Ltd.
 *
 * openGauss is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *
 * http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 * -------------------------------------------------------------------------
 *
 * htap.cpp
 * Interface for main HTAP facade.
 *
 * IDENTIFICATION
 * src/gausskernel/storage/htap/htap.cpp
 *
 * -------------------------------------------------------------------------
 */

#include "htap.h"
#include "htap_common.h"
#include "htap_infra.h"
#include "htap_helpers.h"
#include "mot_engine.h"
#include "../mot/fdw_adapter/gaussdb_config_loader.h"
#include "htap_csn_manager.h"
#include "htap_flush.h"
#include "htap_xlog_redoer.h"
#include "utils/elog.h"
#include "utils/be_module.h"
#include "htap_internal.h"

HTAP_DECLARE_LOGGER(HTAP, HTAP)

namespace htap {
LogLevel g_htapGlobalLogLevel = LogLevel::LL_INFO;
} // namespace htap

bool HTAPIsInitialized()
{
    return htap::HTAPAdaptor::m_initialized;
}

void HTAPOnSessionClose()
{
    htap::HTAPOnSessionClose();
}

ThreadId HTAPStartFlush()
{
    return htap::HTAPInfra::GetInstance()->StartFlush();
}

void HTAPRunWorker()
{
    htap::HTAPFlush::GetInstance()->RunWorker();
}

void HTAPExecFlush()
{
    htap::HTAPFlush::GetInstance()->ExecFlush();
}

ThreadId HTAPStartXLogRedoer()
{
    return htap::HTAPInfra::GetInstance()->StartXLogRedoer();
}

void HTAPRunXlogRedoer()
{
    htap::HTAPXLogRedoer::GetInstance()->RunXLogRedoer();
}

void InitHTAP()
{
    htap::HTAPAdaptor::Init();
}

void TermHTAP()
{
    htap::HTAPAdaptor::Destroy();
}